namespace EyeSoft.Wpf.Facilities.Demo.Configuration
{
	using System;

	using EyeSoft.Mapping;
	using EyeSoft.Wpf.Facilities.Demo.Contract;
	using EyeSoft.Wpf.Facilities.Demo.ViewModels;

	using Mapper = AutoMapper.Mapper;

	internal class DemoMapper : IMapper
	{
		static DemoMapper()
		{
			Mapper.CreateMap<CustomerDto, CustomerViewModel>();
			Mapper.CreateMap<CustomerViewModel, CustomerDto>();

			Mapper.CreateMap<CustomerViewModel, CustomerViewModel>()
				.ForMember(x => x.ErrorCollection, m => m.Ignore());
		}

		public object Map(object source, Type sourceType, Type destinationType)
		{
			return Mapper.Map(source, sourceType, destinationType);
		}

		public T Map<T>(object source)
		{
			return Mapper.Map<T>(source);
		}

		public TDestination Map<TSource, TDestination>(TSource source, TDestination destination)
		{
			return Mapper.Map(source, destination);
		}
	}
}